package test2;

public class a {
    public static void main(String[] args) {
        a A = new a();
        a2 A2 = new a2();
        b B = A.test();
        b B2 = A2.test();
        if(B instanceof b2) {
            System.out.println("B属于b2");
        }else {
            System.out.println("B属于b");
        }
        if(B2 instanceof b2) {
            System.out.println("B2属于b2");
        }else {
            System.out.println("B2属于b");
        }
    }
    public b test() {
        return new b();
    }
}
class a2 extends a {
    public b2 test() {
        return new b2();
    }
}
